﻿from google.appengine.ext import db
from app.forum import models
from datetime import datetime
import hashlib,urllib

class Tags(db.Model):
    alltags = db.StringListProperty()

class Addons(db.Model):
    name = db.StringProperty()
    summary = db.StringProperty(multiline=True)
    author = db.StringProperty()
    version = db.StringProperty()
    catagory = db.StringProperty()
    tags = db.StringListProperty()
    download = db.LinkProperty()
    member = db.ReferenceProperty(models.Members)
    post_on = db.DateTimeProperty(auto_now_add=True)
    edit_on = db.DateTimeProperty(auto_now=True)
    screenshot = db.BlobProperty()
    thumbnail = db.BlobProperty()

    def put_addon(self):
        keyname = "keytags"
        atags = Tags.get_or_insert(keyname)
        for tag in self.tags:
            if tag in atags.alltags:
                pass
            else:
                atags.alltags.append(tag)
                atags.put()
        self.put()

